package com.xiaoshuidi.cloud.module.system.api.apartment;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.system.api.apartment.dto.TaxRateConfigDTO;
import com.xiaoshuidi.cloud.module.system.convert.dept.DeptConvert;
import com.xiaoshuidi.cloud.module.system.dal.dataobject.apartment.ApartmentDO;
import com.xiaoshuidi.cloud.module.system.dal.dataobject.dept.DeptDO;
import com.xiaoshuidi.cloud.module.system.dal.mysql.apartment.ApartmentMapper;
import com.xiaoshuidi.cloud.module.system.enums.apartment.ApartmentManageEnum;
import com.xiaoshuidi.cloud.module.system.service.apartment.ApartmentService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import java.util.List;
import java.util.Objects;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;
import static com.xiaoshuidi.cloud.module.system.enums.ApiConstants.VERSION;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@DubboService(version = VERSION) // 提供 Dubbo RPC 接口，给 Dubbo Consumer 调用
@Validated
public class ApartmentApiImpl implements ApartmentManageApi {

    @Resource
    private ApartmentService apartmentService;

    @Override
    public CommonResult<Boolean> creatApartment(Long apartmentId, String apartmentName) {
        apartmentService.createApartment(apartmentId,apartmentName);
        return CommonResult.success(true);
    }

    @Override
    public CommonResult<Boolean> updateApartment(Long apartmentId, Integer apartmentManageEnumCode) {
        return CommonResult.success(apartmentService.updateApartment(apartmentId,apartmentManageEnumCode));
    }

    @Override
    public CommonResult<List<TaxRateConfigDTO>> getConfigFeesList(Long apartmentId) {
        List<TaxRateConfigDTO> taxRateConfigList = apartmentService.getConfigFeesList(apartmentId);
        return success(taxRateConfigList);
    }
}
